<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增票券定时触发')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-task-add">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">会员电话：</label>
                <div class="col-sm-8">
                    <div class="layui-input-block">
                        <select id="memberSelect" class="form-control m-b" name="memberId" lay-verify="required"></select>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">票券名称：</label>
                <div class="col-sm-8">
                    <div class="layui-input-block">
                        <select id="ticketSelect" class="form-control m-b" name="ticketId" lay-verify="required"></select>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">任务名称：</label>
                <div class="col-sm-8">
                    <input name="jobName" class="form-control" type="text" required>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "system/task"
    $("#form-task-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-task-add').serialize());
        }
    }
    // 获取票券信息
    function getTicketNameList() {
        $.ajax({
            url: '/system/ticket/getTicketList',
            method: 'GET',
            success: function(resp) {
                console.log(resp);
                let ticketArr = resp.data;
                let str = '';
                for (i in ticketArr) {
                    console.log(i);
                    str += '<option value="' + ticketArr[i]["id"] + '">' + ticketArr[i]["ticketName"] + '</option>'
                }
                $("#ticketSelect").append(str);
            }
        })
    }
    // 获取会员信息
    function getMemberList() {
        $.ajax({
            url: '/system/member/getMemberList',
            method: 'GET',
            success: function(resp) {
                console.log(resp);
                let memberArr = resp.data;
                let str = '';
                for (i in memberArr) {
                    console.log(i);
                    str += '<option value="' + memberArr[i]["id"] + '">' + memberArr[i]["memberPhone"] + '</option>'
                }
                $("#memberSelect").append(str);
            }
        })
    }
    getMemberList();
    getTicketNameList();
</script>
</body>
</html>